<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // es5
        // function Person(name,age){
        //     this.name = name ;
        //     this.age = age;
        // }
        // Person.prototype.say = function(){
        //     console.log("你好我是"+this.name);
        // }
        // let xm = new Person("小明",10);
        // console.log(xm);
        // xm.say()

        // es6
        class Person {
            constructor(name,age){
                this.name = name;
                this.age = age;
            }
            say(){
                console.log("你好我是"+this.name);
            }
            paly(){
                console.log("我喜欢玩耍");
            }
        }
        // 给类中添加方法
        Object.assign(Person.prototype,{
            skill(){
                console.log("我有一个牛逼的技能");
            }
        })

        let xm = new Person("小明",10);
        console.log(xm);
        xm.say()
        xm.paly()
        xm.skill()
    </script>
</body>
</html>